<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

class CoreInfoTab {
	var $_heads;
	var $_contents;
	var $_count = 0;
	var $_index = 0;
	
	var $_style;
	var $_headstyle;
	var $_contentstyle;
	
	var $_headvisible = true;
	var $_contentvisible = true;
	
	//constructor
	function CoreInfoTab() {
		
	}
	
	//methods
	function addTab($head, $content) {
		$this->_heads[$this->_count] = $head;
		$this->_contents[$this->_count] = $content;
		$this->_count = $this->_count + 1;
	}
	
	function output() {
		return $this->_format();
	}
	
	function display() {
		echo $this->output();
	}
	
	//
	function _uid() {
		return "xx";
	}
	
	function _uidh($i) {
		return $this->_uid() . $i . 'h';
	}
	
	function _uidc($i) {
		return $this->_uid() . $i . 'c';
	}
	
	function _format() {
		$html = '';
		
		$html .= '<div class="infoTab' . (isset($this->_style)? ' ' . $this->_style : '') . '">' . "\n";
		$html .= '<div class="infoTabHeading' . (isset($this->_headstyle)? ' ' . $this->_headstyle : '') . '">' . "\n";
		$html .= '<ul>';
		for($i=0; $i<$this->_count; $i++) {
			if( $i == $this->_index ) {
				$html .= '<li id="' . $this->_uidh($i) . '" class="c" onMouseOver="dtabover(\'' . $i . '\',\'' . $this->_count . '\',\'' . $this->_uid() . '\')" onMouseOut="dtabout(\'' . $i . '\',\'' . $this->_count . '\',\'' . $this->_uid() . '\')" onClick="dtabclick(\'' . $i . '\',\'' . $this->_count . '\',\'' . $this->_uid() . '\')">' . $this->_heads[$i] . '</li>';
			} else {
				$html .= '<li id="' . $this->_uidh($i) . '" class="d" onMouseOver="dtabover(\'' . $i . '\',\'' . $this->_count . '\',\'' . $this->_uid() . '\')" onMouseOut="dtabout(\'' . $i . '\',\'' . $this->_count . '\',\'' . $this->_uid() . '\')" onClick="dtabclick(\'' . $i . '\',\'' . $this->_count . '\',\'' . $this->_uid() . '\')">' . $this->_heads[$i] . '</li>';
			}
		}
		$html .= '</ul>' . "\n";
		$html .= '</div>' . "\n";
		
		$html .= '<div class="infoTabContent' . (isset($this->_headstyle)? ' ' . $this->_headstyle : '') . '">' . "\n";
		for($i=0; $i<$this->_count; $i++) {
			if( $i == $this->_index ) {
				$html .= '<div id="' . $this->_uidc($i) . '" class="infoTabItem">' . $this->_contents[$i] . '</div>' . "\n";
			} else {
				$html .= '<div id="' . $this->_uidc($i) . '" class="infoTabItem" style="display: none;">' . $this->_contents[$i] . '</div>' . "\n";
			}
		}
		$html .= '</div>' . "\n";
		$html .= '</div>' . "\n";
		
		return $html;
	}
}
//
?>